package com.itheima.d09_jdk8_localDate;

import java.time.LocalDate;
import java.time.LocalDateTime;

public class LocalDateTest {
    public static void main(String[] args) {
        //1.获取当前日期对象
        LocalDate ld = LocalDate.now();

        //2.获取指定日期 年月日
        System.out.println(ld.getYear());
        System.out.println(ld.getMonthValue());
        System.out.println(ld.getDayOfMonth());
        System.out.println(ld.getDayOfWeek());
        System.out.println(ld.getDayOfYear());
        //3.直接修改当前日期
        LocalDate ld1 = ld.withYear(2026);
        System.out.println(ld1);
        System.out.println(ld1.withMonth(12));
        System.out.println(ld1.withDayOfMonth(10));

        //4. 添加指定的时间 年月日
        System.out.println(ld.plusMonths(1));
        System.out.println(ld.plusMonths(-1));

        //5. 减去指定的时间 年月日
        System.out.println(ld.minusDays(1));
        System.out.println(ld.minusDays(-1));


        //6.判断日期的先后
        LocalDate ld2 = LocalDate.of(2026, 12, 10);
        LocalDate ld3 = LocalDate.of(2026, 12, 11);
        if (ld2.isBefore(ld3)){
            System.out.println("ld2在ld3之前");

        }else
        {
            System.out.println("ld2在ld3之后");






        }
    }
}
